﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace EYangFramework.Domain.Repositorys
{
    public interface IRepository<TEntity>
    {
        DbContext DbContext { get; set; }
        IQueryable<TEntity> GetAll();
        List<TEntity> GetAllList();
        IQueryable<TEntity> GetAllNoTracking();
        List<TEntity> GetAllListNoTracking(Expression<Func<TEntity, bool>> predicate);
        Task<List<TEntity>> GetAllListAsync();
        List<TEntity> GetAllList(Expression<Func<TEntity, bool>> predicate);
        T Query<T>(Func<IQueryable<TEntity>, T> queryMethod);
        TEntity Get(Guid id);
        Task<TEntity> GetAsync(Guid id);
        TEntity Single(Expression<Func<TEntity, bool>> predicate);
        Task<TEntity> SingleAsync(Expression<Func<TEntity, bool>> predicate);
        TEntity FirstOrDefault(Guid id);
        Task<TEntity> FirstOrDefaultAsync(Guid id);
        TEntity FirstOrDefault(Expression<Func<TEntity, bool>> predicate);
        Task<TEntity> FirstOrDefaultAsync(Expression<Func<TEntity, bool>> predicate);
        TEntity Insert(TEntity entity);
        void Insert(List<TEntity> entities);
        Task<TEntity> InsertAsync(TEntity entity);
        Task InsertAsync(List<TEntity> entities);
        Guid InsertAndGetId(TEntity entity);
        Task<Guid> InsertAndGetIdAsync(TEntity entity);
        TEntity Update(TEntity entity);
        Task<TEntity> UpdateAsync(TEntity entity);
        TEntity Update(Guid id, Action<TEntity> updateAction);
        void Delete(TEntity entity);
        Task DeleteAsync(TEntity entity);
        void Delete(Guid id);
        Task DeleteAsync(Guid id);
        void Delete(Expression<Func<TEntity, bool>> predicate);
        Task DeleteAsync(Expression<Func<TEntity, bool>> predicate);
        List<TElement> ExcuteQuerySql<TElement>(string sql, params object[] parameters);
        int ExecuteSqlNoQuery(string sql, params object[] parameters);
    }
}
